//
//  AlbumBatchDownloadViewController.m
//  HuiYinMaster
//
//  Created by izhifei-Devon on 2017/5/17.
//  Copyright © 2017年 Rowling. All rights reserved.
//

#import "AlbumBatchDownloadViewController.h"
#import "AlbumBarchDownloadTableViewCell.h"

@interface AlbumBatchDownloadViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation AlbumBatchDownloadViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"%@",NSHomeDirectory());
    self.view.backgroundColor = [UIColor whiteColor];
    self.BaseTableView.delegate = self;
    self.BaseTableView.dataSource = self;
    self.BaseTableView.editing = YES;
    self.BaseTableView.allowsMultipleSelectionDuringEditing = YES;
    [self.view addSubview:self.BaseTableView];
    [self creatUI];
}
-(void)creatUI{
    self.title = @"批量下载";
    UIButton * downloadButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [downloadButton addTarget:self action:@selector(downloading) forControlEvents:UIControlEventTouchUpInside];
    [downloadButton setTitle:@"正在下载" forState:UIControlStateNormal];
    [downloadButton setTitleColor:[UIColor grayColor] forState:UIControlStateHighlighted];
    [downloadButton.titleLabel setFont:[UIFont systemFontOfSize:15]];
    [downloadButton sizeToFit];
    UIBarButtonItem * shareAlbumItem = [[UIBarButtonItem alloc]initWithCustomView:downloadButton];
    self.navigationItem.rightBarButtonItems = @[shareAlbumItem];
    
    
    
    UIView * headView = [[UIView alloc]init];
    headView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:headView];
    [headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view.mas_left).offset(0);
        make.right.mas_equalTo(self.view.mas_right).offset(0);
        make.top.mas_equalTo(self.view.mas_top).offset(0);
        make.size.height.mas_equalTo(70);
    }];
    UIView * headLine = [[UIView alloc]init];
    headLine.backgroundColor = [UIColor grayColor];
    [headView addSubview:headLine];
    [headLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(headView.mas_bottom).offset(0);
        make.left.mas_equalTo(headView.mas_left).offset(0);
        make.right.mas_equalTo(headView.mas_right).offset(0);
        make.size.height.mas_equalTo(0.5);
    }];
    
    self.headLeftLabel = [[UILabel alloc]init];
    self.headLeftLabel.text = @"共 30 集";
    [self.headLeftLabel setFont:[UIFont systemFontOfSize:16]];
    [headView addSubview:self.headLeftLabel];
    [self.headLeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(headView.mas_left).offset(10);
        make.top.mas_equalTo(headView.mas_top).offset(0);
        make.bottom.mas_equalTo(headView.mas_bottom).offset(0);
        make.size.width.mas_equalTo(120);
    }];
    self.headRightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.headRightButton addTarget:self action:@selector(choose) forControlEvents:UIControlEventTouchUpInside];
    [self.headRightButton setTitle:@"选集 (1-20)" forState:UIControlStateNormal];
    [self.headRightButton.titleLabel setFont:[UIFont systemFontOfSize:16]];
    [self.headRightButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [headView addSubview:self.headRightButton];
    [self.headRightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(headView.mas_right);
        make.top.mas_equalTo(headView.mas_top);
        make.bottom.mas_equalTo(headView.mas_bottom);
        make.size.width.mas_equalTo(120);
    }];
    
    UIView * footView = [[UIView alloc]init];
    footView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:footView];
    [footView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view.mas_left).offset(0);
        make.right.mas_equalTo(self.view.mas_right).offset(0);
        make.bottom.mas_equalTo(self.view.mas_bottom).offset(0);
        make.height.mas_equalTo(70);
    }];
    UIView * footLine = [[UIView alloc]init];
    footLine.backgroundColor = [UIColor grayColor];
    [footView addSubview:footLine];
    [footLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(footView.mas_left).offset(0);
        make.right.mas_equalTo(footView.mas_right).offset(0);
        make.top.mas_equalTo(footView.mas_top).offset(0);
        make.height.mas_equalTo(0.5);
    }];
    
    UIButton * footLeftButton = [[UIButton alloc]init];
    [footLeftButton setTitle:@"立即下载" forState:UIControlStateNormal];
    [footLeftButton addTarget:self action:@selector(downloadNow) forControlEvents:UIControlEventTouchUpInside];
    [footLeftButton.titleLabel setFont:[UIFont systemFontOfSize:17]];
    [footLeftButton setBackgroundColor: XMColor(108, 34, 42)];
    [footView addSubview:footLeftButton];
    [footLeftButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(footView.mas_left).offset(20);
        make.top.mas_equalTo(footView.mas_top).offset(20);
        make.bottom.mas_equalTo(footView.mas_bottom).offset(-20);
        make.size.width.mas_equalTo(120);
    }];
    
    UIButton * footRightButton = [[UIButton alloc]init];
    [footRightButton setTitle:@"全部选择" forState:UIControlStateNormal];
    [footRightButton addTarget:self action:@selector(chooseAll) forControlEvents:UIControlEventTouchUpInside];
    [footRightButton.titleLabel setFont:[UIFont systemFontOfSize:17]];
    [footRightButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [footView addSubview:footRightButton];
    [footRightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(footView.mas_right).offset(-20);
        make.top.mas_equalTo(footView.mas_top).offset(20);
        make.bottom.mas_equalTo(footView.mas_bottom).offset(-20);
        make.size.width.mas_equalTo(90);
    }];
    
    UIImageView * selectAllImg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_select"]];
    [footView addSubview:selectAllImg];
    [selectAllImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(footRightButton.mas_left).offset(-10);
        make.width.mas_equalTo(20);
        make.height.mas_equalTo(20);
        make.centerY.mas_equalTo(footRightButton.mas_centerY);
    }];
    
    [self.BaseTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.view.mas_left);
        make.right.mas_equalTo(self.view.mas_right);
        make.top.mas_equalTo(headView.mas_bottom);
        make.bottom.mas_equalTo(footView.mas_top);
    }];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  20;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    AlbumBarchDownloadTableViewCell * cell = [AlbumBarchDownloadTableViewCell fastLoginView];
    return  cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return  70;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark -正在下载
-(void)downloading{
    NSLog(@"正在下载");
}
-(void)chooseAll{
    NSLog(@"选择全部");
}
-(void)downloadNow{
    NSLog(@"立即下载");
}
-(void)choose{
    NSLog(@"选集");
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
